package org.come.Frame;

import com.tool.tcpimg.UIUtils;
import come.tool.Fighting.FightingMixDeal;
import org.come.Jpanel.SyntheticGourdDollJpanel;
import org.come.until.FormsManagement;
import org.come.until.Music;

import javax.swing.*;
import javax.swing.plaf.basic.BasicInternalFrameUI;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class SyntheticGourdDollJframe extends JInternalFrame implements MouseListener {
    private SyntheticGourdDollJpanel syntheticGourdDollJpanel;
    private int first_x;
    private int first_y;

    public static SyntheticGourdDollJframe getSyntheticGourdDollJframe() {
        return (SyntheticGourdDollJframe) FormsManagement.getInternalForm(702).getFrame();
    }
    public static void openSyntheticGourdDollJframe() {
        FormsManagement.showForm(702);
        getSyntheticGourdDollJframe().getSyntheticGourdDollJpanel().clear();
    }

    public SyntheticGourdDollJframe() throws Exception {
        this.add(this.syntheticGourdDollJpanel = new SyntheticGourdDollJpanel());

        this.setBorder(BorderFactory.createEmptyBorder());
        ((BasicInternalFrameUI)this.getUI()).setNorthPane(null);
        this.setBounds(400, 100, 659, 461);
        this.setBackground(UIUtils.Color_BACK);
        this.pack();
        this.setDefaultCloseOperation(3);
        this.setVisible(false);
        this.addMouseListener(this);
        this.addMouseMotionListener(new MouseMotionListener() {
            @Override
            public void mouseMoved(final MouseEvent e) {
            }

            @Override
            public void mouseDragged(final MouseEvent e) {
                if (SyntheticGourdDollJframe.this.isVisible()) {
                    final int x = e.getX() - SyntheticGourdDollJframe.this.first_x;
                    final int y = e.getY() - SyntheticGourdDollJframe.this.first_y;
                    SyntheticGourdDollJframe.this.setBounds(x + SyntheticGourdDollJframe.this.getX(), y + SyntheticGourdDollJframe.this.getY(), SyntheticGourdDollJframe.this.getWidth(), SyntheticGourdDollJframe.this.getHeight());
                }
            }
        });
    }

    @Override
    public void mouseClicked(MouseEvent e) {

    }

    @Override
    public void mousePressed(MouseEvent e) {
        Music.addyinxiao("关闭窗口.mp3");
        if (e.isMetaDown()) {
            FightingMixDeal.zdhh = 0;
            FormsManagement.HideForm(702);
        } else {
            FormsManagement.Switchinglevel(702);
        }

        this.first_x = e.getX();
        this.first_y = e.getY();
    }

    @Override
    public void mouseReleased(MouseEvent e) {

    }

    @Override
    public void mouseEntered(MouseEvent e) {

    }

    @Override
    public void mouseExited(MouseEvent e) {

    }

    public SyntheticGourdDollJpanel getSyntheticGourdDollJpanel() {
        return syntheticGourdDollJpanel;
    }

    public void setSyntheticGourdDollJpanel(SyntheticGourdDollJpanel syntheticGourdDollJpanel) {
        this.syntheticGourdDollJpanel = syntheticGourdDollJpanel;
    }
}
